package com.zh.harmony.butterknife.slice;

import com.zh.harmony.butterknife.*;
import com.zh.harmony.butterknife.annotations.Bind;
import com.zh.harmony.butterknife.annotations.OnClick;
import com.zh.harmony.butterknife.annotations.OnLongClick;
import com.zh.harmony.butterknife.util.ToastUtil;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.window.service.WindowManager;

public class MainAbilitySlice extends AbilitySlice {
    @Bind(ResourceTable.Id_btn)
    Button vBtn;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        //沉浸式显示，必须在setUIContent之前
        getWindow().addFlags(WindowManager.LayoutConfig.MARK_TRANSLUCENT_STATUS);
        setUIContent(ResourceTable.Layout_ability_main);
        ButterKnife.inject(this);
        vBtn.setText("跳转到ListAbilitySlice");
    }

    @OnClick(values = {ResourceTable.Id_btn})
    void onClick() {
        Intent intent = new Intent();
        intent.setParam("data", "你好，鸿蒙");
        present(new ListAbilitySlice(), intent);
    }

    @OnLongClick(values = {ResourceTable.Id_btn})
    void onLongClick() {
        ToastUtil.toast(this, "长按");
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
